﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FYP14
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnFirst_Click(object sender, EventArgs e)
        {
            Response.Redirect("Users.aspx");
        }

        protected void btnSecond_Click(object sender, EventArgs e)
        {
            Response.Redirect("viewMedicines.aspx");
        }

        protected void btnThird_Click(object sender, EventArgs e)
        {
            Response.Redirect("viewLabTests.aspx");
        }

        protected void btnFourth_Click(object sender, EventArgs e)
        {
            Response.Redirect("viewSymptom.aspx");
        }
        protected void btnVisit_Click(object sender, EventArgs e)
        {
            Response.Redirect("Visit.aspx");
        }

        [System.Web.Services.WebMethod]
        public static string GetServerDate()
        {
            HttpContext.Current.Session.Remove("Login");
            //HttpContext.Current.Response.Redirect("Login.aspx");
            return DateTime.Now.ToLocalTime().ToString();
            //redirect();
        }

        [System.Web.Services.WebMethod]
        public static string EditProfile()
        {
            //HttpContext.Current.Session.Remove("Login");
            //HttpContext.Current.Response.Redirect("Login.aspx");
            return ((DataTable)HttpContext.Current.Session["login"]).Rows[0]["application_user_id"].ToString();
            //redirect();
        }

        [System.Web.Services.WebMethod]
        public static string RedirectHome()
        {
            if (HttpContext.Current.Session["login"] == null)
                HttpContext.Current.Response.Redirect("Login.aspx");

            DataTable dt = ((DataTable)HttpContext.Current.Session["login"]);
            if (Convert.ToInt32(dt.Rows[0]["user_role_id"]) == (Int32)FYP14.Login.usertype.Admin)
            {
                return "Default.aspx";
            }
            else if (Convert.ToInt32(dt.Rows[0]["user_role_id"]) == (Int32)FYP14.Login.usertype.Doctor)
            {
                return "DoctorDefault.aspx";
            }
            return "ReceptionistDefault.aspx";
        }
    }
}